<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="p" uri="/WEB-INF/page_qidi.tld"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>管理公告通知</title>
		<link type="text/css" rel="stylesheet" href="http://img.xxt.m-school.cn/wisdom/style/style.css">
		<script type="text/javascript" language="javascript"
			src="http://img.xxt.m-school.cn/wisdom/js/mode.js"></script>
		<script type="text/javascript" language="javascript"
			src="http://img.xxt.m-school.cn/wisdom/js/tableList.js"></script>
		<script type='text/javascript'
			src='${pageContext.request.contextPath}/dwr/interface/examDwr.js'></script>
		<script type='text/javascript'
			src='${pageContext.request.contextPath}/dwr/engine.js'></script>
		<script type='text/javascript'
			src='${pageContext.request.contextPath}/dwr/util.js'></script>
		<script type="text/javascript" language="javascript">
function getKsrc(){
	var ksrc = document.getElementById('ksrcSelect').value;
    var text = document.getElementById('ksrcSelect').options[document.getElementById('ksrcSelect').selectedIndex].text;
	document.getElementById('ksrcname').value=text;
	document.getElementById('scexid').value=ksrc;
	document.getElementById('scexname').value=text;
	examDwr.getExamClass(ksrc, setBj);
}
function setBj(data){
	DWRUtil.removeAllOptions("bjSelect");
	DWRUtil.addOptions("bjSelect", {"":"\u8bf7\u9009\u62e9\u73ed\u7ea7"});
	DWRUtil.addOptions("bjSelect", data);
}
function getBj(){
	var ksbj = document.getElementById('bjSelect').value;
	var ksrc = document.getElementById('ksrcSelect').value;
	
	var text = document.getElementById('bjSelect').options[document.getElementById('bjSelect').selectedIndex].text;
	
	document.getElementById('scbj').value=ksbj;
	document.getElementById('scbjname').value=text;
	
	examDwr.getExamKm(ksbj,ksrc, setKm);
}

function getKm(){

	var kskm = document.getElementById('kmSelect').value;
	var text = document.getElementById('kmSelect').options[document.getElementById('kmSelect').selectedIndex].text;
	document.getElementById('sckm').value=kskm;
	document.getElementById('sckmname').value=text;

}

function setKm(data){
	DWRUtil.removeAllOptions("kmSelect");
	DWRUtil.addOptions("kmSelect", {"":"请选择科目"});
	DWRUtil.addOptions("kmSelect", data);
}
function submitForm(){
	var str="";
	if(document.getElementById('ksrcSelect').value==0){
		str+="请选择考试日程\n";
	}
	if(document.getElementById('bjSelect').value==0){
		str+="请选择考试班级\n";
	}
	if(document.getElementById('kmSelect').value==0){
		str+="请选择考试科目\n";
	}
	if(str!=""){
		alert(str);
	}else{
		document.getElementById('kstype').value="1";
		document.getElementById('queryAll').click();
	}
	
	
}

function GetXslForm(){
	var str="";
	if(document.getElementById('ksrcSelect').value==0){
		str+="请选择考试日程\n";
	}
	if(document.getElementById('bjSelect').value==0){
		str+="请选择考试班级\n";
	}
	if(document.getElementById('kmSelect').value==0){
		str+="请选择考试科目\n";
	}
	if(str!=""){
		alert(str);
	}else{
		document.getElementById('kstype').value="0";
		document.getElementById('queryAll').click();
	}
	
	
}

function OpenUpload(){
	var str="";
	if(document.getElementById('ksrcSelect').value==0){
		str+="请选择考试日程\n";
	}
	if(document.getElementById('bjSelect').value==0){
		str+="请选择考试班级\n";
	}
	if(document.getElementById('kmSelect').value==0){
		str+="请选择考试科目\n";
	}
	if(str!=""){
		alert(str);
	}else{
		addListGroup('uploadExcel');
	}
	
	
}

function submitInsert(){
	document.getElementById('insertScore').click();
}

function submitExcel(){
	var url = document.getElementById('scoreFile').value;
	var p = url.lastIndexOf(".");
	var str = url.substring(p);
	if(str!=".xls"){
		alert("请选择正确的文件，必须为Excel表格文件！");
	}else{
		document.getElementById('uploadExcelButton').click();
	}
}

function resetInsert(){
	document.getElementById('resetScore').click();
}
function checkNum(a){
	var temp = "${requestScope.listVo.fz}";
	if(isNaN(a.value)){
		alert("请输入正确的成绩数据！");
		a.focus(); 
		return false; 
	}else{
		if(parseFloat(temp)<parseFloat(a.value)){
			alert("该科分制为"+temp+"分,输入成绩不得大于"+temp);
			a.focus();
			return false; 
		}
		if(parseFloat(a.value)<0){
			alert("成绩不得小于0请输入正确的成绩！");
			a.focus(); 
			return false; 
		}
	}
	
}


</script>
	</head>

	<body class="conBody" onLoad="tableList()" onResize="tableList()">
		<table width="100%" height="100%" border="0" align="center"
			cellpadding="0" cellspacing="0">
			<tr>
				<td id="conListAlt">
					<form action="examAction!getOneExamScore" method="post">
						<table border="0" cellspacing="0" cellpadding="0"
							class="topSelectStyle">
							<tr>
								<td>
									考试日程：
								</td>
								<td class="bodyBlock">
									<select id="ksrcSelect" name="ksrcSelect" class="comInputStyle"
										onchange="getKsrc()">
										<option value="0">
											请选择考试日程
										</option>
										<s:iterator value="#session.ksrc" id="ksrc">
											<option value="<s:property value="examId"/>">
												<s:property value="examName" />
											</option>
										</s:iterator>
									</select>
								</td>
								<td>
									考试班级：
								</td>
								<td class="bodyBlock">
									<select id="bjSelect" name="bjSelect" class="comInputStyle"
										onchange="getBj()">
										<option value="0">
											请选择班级
										</option>
									</select>
								</td>
								<td>
									考试科目：
								</td>
								<td class="bodyBlock">
									<select id="kmSelect" name="kmSelect" class="comInputStyle"
										onchange="getKm()">
										<option value="0">
											请选择科目
										</option>
									</select>
								</td>
								<td class="buttonOut">
									<table width="100%" border="0" cellspacing="0" cellpadding="0">
										<tr>
											<td class="buttonLeft"></td>
											<td class="buttonCenter" onMouseDown="buttonDown(this)"
												onMouseOver="buttonOver(this)" onMouseOut="buttonOut(this)">
												<a href="#" onclick="submitForm()">确 定</a>
											</td>
											<td class="buttonRight"></td>
										</tr>
									</table>
								</td>
								<!--  
								<td class="buttonOut">
									<table width="100%" border="0" cellspacing="0" cellpadding="0">
										<tr>
											<td class="buttonLeft"></td>
											<td class="buttonCenter" onMouseDown="buttonDown(this)"
												onMouseOver="buttonOver(this)" onMouseOut="buttonOut(this)">
												<a href="#" onclick="GetXslForm()">下载成绩模板文件</a>
											</td>
											<td class="buttonRight"></td>
										</tr>
									</table>
								</td>

								<td class="buttonOut">
									<table width="100%" border="0" cellspacing="0" cellpadding="0">
										<tr>
											<td class="buttonLeft"></td>
											<td class="buttonCenter" onMouseDown="buttonDown(this)"
												onMouseOver="buttonOver(this)" onMouseOut="buttonOut(this)">
												<a href="#" onclick="OpenUpload()">成绩导入</a>
											</td>
											<td class="buttonRight"></td>
										</tr>
									</table>
								</td>
								-->
							</tr>
						</table>
						<input type="hidden" id="ksrcname" name="ksrcname" value="">
						<input type="hidden" id="kstype" name="kstype" value="">
						<input type="submit" id="queryAll" style="display: none;" />
					</form>
				</td>
				<!--  
	<td>
	<s:form action="examAction!importScoreExcel" method="POST" enctype="multipart/form-data">
	<s:file name ="scoreFile" label ="Image File" />       
        <s:submit /> 
    <input type="hidden" id="scexid" name="scexid" value="">
    <input type="hidden" id="scexname" name="scexname" value="">
    <input type="hidden" id="scbj" name="scbj" value="">
    <input type="hidden" id="scbjname" name="scbjname" value="">
    <input type="hidden" id="sckm" name="sckm" value="">
    <input type="hidden" id="sckmname" name="sckmname" value="">
	</s:form>
	
	</td>
	-->
			</tr>
			<tr>
				<td align="left" valign="top">
					<table border="0" id="mainThead" cellpadding="0" cellspacing="0"
						class="listHeadBg">
						<tr>
							<th>
								&nbsp;
							</th>
							<th>
								学生姓名
							</th>
							<th>
								所在班级
							</th>
							<th>
								考试科目
							</th>
							<th>
								成绩
							</th>
						</tr>
					</table>
					<div id="srcollTable">

						<form action="examAction!insertScore" method="post">
							<table width="100%" border="0" cellspacing="0" cellpadding="0"
								id="mainTbody" class="covBodyTd">
								<tr>
									<th>
										&nbsp;
									</th>
									<th>
										学生姓名
									</th>
									<th>
										所在班级
									</th>
									<th>
										考试科目
									</th>
									<th>
										成绩
									</th>
								</tr>
								<s:iterator value="#request.listVo.scoreList" id="scorelist">
									<tr onMouseOver="this.className = 'tronMouseover'"
										onMouseOut="this.className = 'tronMouseout'"
										class="tronMouseout">
										<td>
											&nbsp;
										</td>
										<td align="center">
											<s:property value="stuname" />
										</td>
										<td align="center">
											<s:property value="bjname" />
										</td>
										<td align="center">
											${requestScope.listVo.kmname}
										</td>
										<td align="center">
												<input name="onescore" type="text"
													value="<s:property value="scYuwen"/>" size="14"
													onblur="checkNum(this)">
											<input type="hidden" name="stuid"
												value="<s:property value="stuid"/>">
										</td>
									</tr>
								</s:iterator>
							</table>
							<input type="hidden" name="exid"
								value="${requestScope.listVo.exid}">
							<input type="hidden" name="bjid"
								value="${requestScope.listVo.bjid}">
							<input type="hidden" name="kmid"
								value="${requestScope.listVo.kmid}">

							<input type="submit" id="insertScore" style="display: none;" />
							<input type="reset" id="resetScore" style="display: none;" />
						</form>

					</div>
				</td>
			</tr>

			<tr>
				<td height="50" id="buttonCov">
					<table border="0" cellspacing="0" cellpadding="0">
						<s:if test='%{#request.listVo.exid!=""}'>
							<tr>
								<td class="buttonOut">
									<table width="100%" border="0" cellspacing="0" cellpadding="0">
										<tr>
											<td class="buttonLeft"></td>
											<td class="buttonCenter" onMouseDown="buttonDown(this)"
												onMouseOver="buttonOver(this)" onMouseOut="buttonOut(this)">
												<a href="#" onclick="submitInsert()">确 定</a>
											</td>
											<td class="buttonRight"></td>
										</tr>
									</table>
								</td>
								<td class="buttonOut">
									<table width="100%" border="0" cellspacing="0" cellpadding="0">
										<tr>
											<td class="buttonLeft"></td>
											<td class="buttonCenter" onMouseDown="buttonDown(this)"
												onMouseOver="buttonOver(this)" onMouseOut="buttonOut(this)">
												<a href="#" onclick="resetInsert()">清 空</a>
											</td>
											<td class="buttonRight"></td>
										</tr>
									</table>
								</td>
							</tr>
						</s:if>
					</table>
				</td>
			</tr>
		</table>

		<div id="float_bg">
			<iframe width="100%" height="100%" scrolling="no" frameborder="0"></iframe>
		</div>
		<div id="float_zz"></div>
		<div id="uploadExcel"
			style="width: 400px; display: none; position: absolute; z-index: 5000">
			<s:form action="examAction!importScoreExcel" method="post"
				enctype="multipart/form-data" theme="simple" id="uploadForm">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td>
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td class="floatDivTL">
										<img src="http://img.xxt.m-school.cn/wisdom/images/floatDivTL.gif" width="3"
											height="27">
									</td>
									<td class="floatDivTC">
										<table width="100%" border="0" cellspacing="0" cellpadding="0">
											<tr>
												<td align="left">
													<div class="phoneTitle">
														成绩导入
													</div>
												</td>
												<td align="right">
													<img src="http://img.xxt.m-school.cn/wisdom/images/floatDivClose.gif"
														width="9" height="9"
														style="margin-right: 10px; cursor: pointer;" border="0"
														onClick="closelistDiv('uploadExcel')">
												</td>
											</tr>
										</table>
									</td>
									<td class="floatDivTR">
										<img src="http://img.xxt.m-school.cn/wisdom/images/floatDivTR.gif" width="3"
											height="27">
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td align="center" valign="top" class="floatCenter">
							<table border="0" align="center" cellpadding="0" cellspacing="6">
								<tr>
									<td width="30%" align="right">
										导入文件：
									</td>
									<td align="left">
										<s:file id="scoreFile" name="scoreFile" label="Image File" />

									</td>
								</tr>
								<tr>
									<td colspan="2" align="center" valign="top">
										请先下载模板填写数据后导入成绩，请不要EXCEL内除成绩以外的数据，否则将导致导入失败！
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td align="center" height="36" class="floatBody">
							<input type="button" value="提交" onclick="submitExcel()">
						</td>
					</tr>
				</table>
				<input type="hidden" id="scexid" name="scexid" value="">
				<input type="hidden" id="scexname" name="scexname" value="">
				<input type="hidden" id="scbj" name="scbj" value="">
				<input type="hidden" id="scbjname" name="scbjname" value="">
				<input type="hidden" id="sckm" name="sckm" value="">
				<input type="hidden" id="sckmname" name="sckmname" value="">

				<input type="submit" id="uploadExcelButton" style="display: none;" />
			</s:form>
		</div>


	</body>
	<%
		if (null != request.getAttribute("tips")
				&& !"".equals(request.getAttribute("tips"))) {
	%>j
	<script type="text/javascript">
			alert('${requestScope.tips}');
		</script>
	<%
		}
	%>
</html>
